import 'package:flutter_flux/flutter_flux.dart';
import 'package:freemusic/model/AbstractDiss.dart';
import 'package:freemusic/model/AbstractSong.dart';
import 'package:freemusic/model/netease/NeteaseAccount.dart';
import 'package:freemusic/model/netease/NeteaseDiss.dart';
import 'package:freemusic/model/qq/QQDiss.dart';
import 'package:freemusic/model/qq/QQAccount.dart';

class CloudDissStore extends Store {
  List<QQDiss> _qqDisses = List();
  List<NeteaseDiss> _neteaseDisses = List();

  AbstractDiss _current;
  List<AbstractSong> _dissSongs = List();
  QQAccount _qqAccount ;
  NeteaseAccount _neteaseAccount;

  CloudDissStore() {
    triggerOnAction(changeQQDisses, (List<QQDiss> qqDisses) {
      this._qqDisses = qqDisses;
    });
    triggerOnAction(changeDiss, (AbstractDiss diss) {
      _current = diss;
    });
    triggerOnAction(changeDissSongs, (List<AbstractSong> dissSongs) {
      _dissSongs = dissSongs;
    });
    triggerOnAction(changeNeteaseDisses, (List<NeteaseDiss> disses) {
      _neteaseDisses = disses;
    });
    triggerOnAction(changeQQAccount, (QQAccount account){
      _qqAccount = account;
    });
    triggerOnAction(changeNeteaseAccount, (NeteaseAccount account){
      _neteaseAccount = account;
    });
  }

  List<QQDiss> get qqDisses => _qqDisses;
  AbstractDiss get current => _current;
  List<AbstractSong> get dissSong => _dissSongs;
  List<NeteaseDiss> get neteaseDisses => _neteaseDisses;
  QQAccount get qqAccount => _qqAccount;
  NeteaseAccount get neteaseAccount => _neteaseAccount;
}

final StoreToken cloudDissToken = StoreToken(CloudDissStore());

final Action<List<QQDiss>> changeQQDisses = Action();
final Action<List<NeteaseDiss>> changeNeteaseDisses = Action();

final Action<AbstractDiss> changeDiss = Action();
final Action<List<AbstractSong>> changeDissSongs = Action();

final Action<QQAccount> changeQQAccount = Action();
final Action<NeteaseAccount> changeNeteaseAccount = Action();
